package com.heihei.watermark;

import com.heihei.config.ConfigProperties;
import com.heihei.util.ImgUtil;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class StartWaterMark {
    public static void main(String[] args) throws IOException {
        BufferedImage img = ImgUtil.loadImageLocal("C:\\Users\\12851\\Desktop\\图片测试\\表情包\\01.jpg");
        Graphics2D g = img.createGraphics();
        int width = img.getWidth();
        int height = img.getHeight();

        //水印图片色彩以及透明度/255, 255, 0
        Color markContentColor = new Color(74, 74, 74, 250);
        g.setColor(markContentColor);
        //水印字体
        Font font = new Font("宋体", Font.PLAIN, 14);
        g.setFont(font);
        //添加的内容，x，y
        g.drawString("helloWord", width * 2 / 3, height - 24);
        g.dispose();

        ImageIO.write(img, "jpg", new File("C:\\Users\\12851\\Desktop\\图片测试\\123.jpg"));
    }
}